package demo4;

import java.util.*;

public class IsCompleteTree {
    public boolean isCompleteTree (TreeNode root) {
        if(root == null) {
            return true;
        }
        Queue<TreeNode> queue = new LinkedList<>();
        queue.add(root);
        boolean flag = true;
        while(!queue.isEmpty()) {
            TreeNode poll = queue.poll();
            if(poll != null && !flag ) {
                return false;
            }
            if(poll == null) {
                flag = false;
                continue;
            }
            queue.offer(poll.left);
            queue.offer(poll.right);
        }
        Queue<TreeNode> list = new LinkedList<>();
        list.remove();        Stack<TreeNode> stack2 = new Stack<>();// 看是否已经存储过

        return true;
    }
}
